(function (vc) {
    vc.extends({
        data: {
            chooseGoldInfo: {
                golds: [],
                communityName: '',
                curGold:{}
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseGold', 'openChooseGoldModel', function (_param) {
                $('#chooseGoldModel').modal('show');
                $that.chooseGoldInfo.curGold = _param;
                $that._refreshChooseGoldInfo();
                $that._loadAllGoldInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllGoldInfo: function (_page, _row, _name) {
                let param = {
                    params: {
                        page: _page,
                        row: _row,
                        communityName: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('/gold.listGold',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.chooseGoldInfo.golds = _json.data;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseGold: function (_gold) {
                vc.copyObject(_gold,$that.chooseGoldInfo.curGold);
                $('#chooseGoldModel').modal('hide');
            },
            queryLabels: function () {
                $that._loadAllGoldInfo(1, 10, $that.chooseGoldInfo.communityName);
            },
            _refreshChooseGoldInfo: function () {
                $that.chooseGoldInfo.communityName = "";
            }
        }

    });
})(window.vc);
